package com.xiaoshuidi.cloud.module.contract.enums.bill;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;


/*
*
* 收款周期类型
* */
@Getter
@AllArgsConstructor
public enum OrderCollectionTypeEnum {


    MONTHLY_PAYMENT(1,"月付"),
    QUARTERLY_PAYMENT(3,"季付"),
    HALFYEAR_PAYMENT(6,"半年付"),
    YEAR_PAYMENT(12,"年付"),
    OTHER_PAYMENT(0,"其他"),

        ;
    /**
     * 编码
     */
    private final Integer code;
    private final String value;

    private static Map<Integer, OrderCollectionTypeEnum> enumMap = new HashMap<>();
    static {
        OrderCollectionTypeEnum[] values = OrderCollectionTypeEnum.values();
        for (OrderCollectionTypeEnum value : values) {
            enumMap.put(value.getCode(), value);
        }
    }
    public static OrderCollectionTypeEnum getEnum(Integer num){
        return enumMap.get(num);
    }

    public static Integer getCouponStatusByCode(int code) {
        OrderCollectionTypeEnum[] orderCollectionTypeEnums = values();
        for (OrderCollectionTypeEnum orderCollectionTypeEnum : orderCollectionTypeEnums) {
            if (orderCollectionTypeEnum.code==code) {
                return orderCollectionTypeEnum.code;
            }
        }
        return null;
    }
}
